import os
path = '/data/UWdevkit/Online/Data/train'
write_file = '/data/UWdevkit/Online/ImageSets/train.txt'
with open(write_file,"w") as wf:
    # file
    id = 0
    for file in os.listdir(path):
        if os.path.isfile(os.path.join(path,file)) == True:
            id += 1
            print(file + ' '+ str(id))
            wf.write(file.split('.')[0] +"\n")
    # sub dir
    # for dir in os.listdir(path):
    #     if os.path.isdir(os.path.join(path, dir)) == True:
    #         for file in os.listdir(os.path.join(path, dir)):
    #             # print(os.path.join(path, dir))
    #             if os.path.isfile(os.path.join(path, dir, file)) == True:
    #                 id += 1
    #                 print(dir+'/'+file + ' ' + str(id))
    #                 wf.write(dir+'/'+file.split('.')[0] + ' '+ str(id) + "\n")
